package com.veepeak.server.domain;

import com.veepeak.server.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.util.Date;

@Entity
@DynamicUpdate
@DynamicInsert
@Table(name = "command_log")
@Data
@EqualsAndHashCode(callSuper = false)
@ToString
public class DtcCommandLog extends BaseEntity {
    @ManyToOne
    @JoinColumn(name = "user_id")
    private User user;
    @ManyToOne
    @JoinColumn(name = "obd_id")
    private Obd obd;
    @ManyToOne
    @JoinColumn(name = "vehicle_id")
    private Vehicle vehicle;
    private String category; //故障代码类型

    private String pid; //故障PID代码

    private String faultTime; //产生故障的时间
    private String saveTime; //故障上传时间

    public final static String CATEGORY_DTC_CONFIRM = "dtc_confirm"; //故障代码
    public final static String CATEGORY_DTC_PENDING = "dtc_pending"; //故障代码
    public final static String CATEGORY_FREEZE = "freeze"; //冻结帧
    public final static String CATEGORY_EXHAUST = "exhaust"; //尾气检测

    public DtcCommandLog(){}

    public DtcCommandLog(User user, Obd obd, Vehicle vehicle){
        this.user = user;
        this.obd = obd;
        this.vehicle = vehicle;
    }
}
